package com.le.medium.class2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * 给定一个数组arr，求差值为k的去重数字对
 */
public class Problem01_SubvalueEqualK {

    public static List<List<Integer>> process(int[] arr, int k) {
        if (arr == null || arr.length == 0) {
            return null;
        }
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < arr.length; i++) {
            set.add(arr[i]);
        }
        List<List<Integer>> list = new ArrayList<>();
        for (Integer cur : set) {
            if (set.contains(cur + k)) {
                list.add(Arrays.asList(cur, cur + k));
            }
        }
        return list;
    }
}
